$(document).ready(function() {
  if("WebSocket" in window){
    var sock = new WebSocket("ws://localhost:8080");

    sock.onopen = function(){  
      console.log("Socket has been opened!");  
    }

    sock.onmessage = function(message){
      console.log(message);
      document.writeln(message.data + "<br />");
    }
  }else{
    console.log("no sockets supported :-/");
  }
  
});